package org.mentalsmash.tazio.transactions.model.impl;

import java.io.Serializable;

import org.mentalsmash.tazio.transactions.model.InvalidTransactionalObjectException;
import org.mentalsmash.tazio.transactions.user.annotations.PropertyGetter;
import org.mentalsmash.tazio.transactions.user.annotations.PropertySetter;
import org.mentalsmash.tazio.transactions.user.annotations.Transactional;

public interface TxObjectWrapperFactory {

    /**
     * factory method that tries to create a <tt>TxObjectPropxy</tt> for a
     * target object.
     * <p>
     * This method takes care of checking whether exactly one of the interfaces
     * implemented by <code>target</code> is annotated with the
     * {@link Transactional} annotation, and then checks whether that interface
     * has the appropriate {@link PropertyGetter} and {@link PropertySetter}
     * annotations.
     * </p>
     * 
     * @param target
     *            the object to create the proxy for
     * @return an instance of <tt>TxObjectProxy</tt> wrapping
     *         <code>target</code>
     * @throws InvalidTransactionalObjectException
     *             if no suitable interface annotated with the
     *             {@link Transactional} annotation is found
     */
    TxObjectWrapper createTxWrapper(Serializable target);

}